package com.manage.server.controller;


import com.manage.server.pojo.Admin;
import com.manage.server.pojo.RespBean;
import com.manage.server.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zl
 * @since 2021-05-26
 */
@RestController
@RequestMapping("admin")
public class AdminController {
    @Autowired
    private IAdminService adminService;
    /**
     * <p>
     *  查找用户
     * </p>
     *
     * @author zl
     * @since 2021-05-26
     */
    @GetMapping("findAdmin")
    public Admin findAdmin() {
        return adminService.findAdmin();
    }
    /**
     * <p>
     *  更新用户
     * </p>
     *
     * @author zl
     * @since 2021-05-26
     */
    @PutMapping("updateAdmin")
    public RespBean updateAdmin(@RequestBody Admin admin) {
        if (adminService.updateAdmin(admin)) {
            return RespBean.success("更新成功!");
        } else {
            return RespBean.error("更新失败!");
        }
    }
}
